<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        {{mapMsg}}  <br />
        {{fnMsg()}}
        {{fnMsg()}}
        {{fnMsg()}}
        <button @click="changeMsg">changeMsg</button>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                msg:"hello world"
            },
            methods:{
                changeMsg(){
                    this.mapMsg = "hello Vue.js"
                },
                fnMsg(){
                    console.log(2);
                    this.msg = "hello Vue.js"
                    return  this.msg
                }
            },
            //方法调用一次执行一次
            //计算属性有缓存   只会执行一次
            computed:{
                mapMsg:{
                    get(){
                        console.log(1);
                        return this.msg
                    },
                    set(value){
                        this.msg = value
                    }
                }
            }
        })
    </script>
</body>
</html>